﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;
using System.IO;
using WMPLib;

namespace TankController
{
    public partial class FormSelecionarConfiguracao : Form
    {
        private FormPrincipal formPrincipal;
        private WindowsMediaPlayer player = new WindowsMediaPlayer();

        public FormSelecionarConfiguracao(FormPrincipal formPrincipal)
        {
            InitializeComponent();

            this.formPrincipal = formPrincipal;
        }

        private void btnConfiguracaoA_Click(object sender, EventArgs e)
        {
            Global.TipoConfiguracao = TipoConfiguracao.ConfiguracaoA;

            this.Close();
        }

        private void btnConfiguracaoB_Click(object sender, EventArgs e)
        {
            Global.TipoConfiguracao = TipoConfiguracao.ConfiguracaoB;

            this.Close();
        }

        private void btnConfiguracaoC_Click(object sender, EventArgs e)
        {
            Global.TipoConfiguracao = TipoConfiguracao.ConfiguracaoC;

            this.Close();
        }

        private void btnConfiguracaoD_Click(object sender, EventArgs e)
        {
            Global.TipoConfiguracao = TipoConfiguracao.ConfiguracaoD;

            this.Close();
        }

        private void FormSelecionarConfiguracao_Shown(object sender, EventArgs e)
        {
            player.URL = Path.GetDirectoryName(Application.ExecutablePath) + @"\Sounds\choose.mp3";

            player.settings.autoStart = false;
            player.settings.setMode("loop", true);

            player.controls.play();
        }
        
        private void wavPlayer_LoadCompleted(object sender, AsyncCompletedEventArgs e)
        {
            ((System.Media.SoundPlayer)sender).Play();
        }

        private void btnConfiguracao_MouseEnter(object sender, EventArgs e)
        {
            SoundPlayer simpleSound = new SoundPlayer(@".\Sounds\option.wav");
            
            simpleSound.Play();
        }

        private void btnConfiguracao_MouseDown(object sender, MouseEventArgs e)
        {
            SoundPlayer simpleSound = new SoundPlayer(@".\Sounds\push.wav");

            simpleSound.Play();
        }

        private void FormSelecionarConfiguracao_FormClosed(object sender, FormClosedEventArgs e)
        {
            player.controls.stop();
        }
    }
}
